/*
 * Copyright (c) Honor Technologies Co., Ltd. 2019-2020. All rights reserved.
 */

package com.kll.tv;

import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.kll.tv.views.WellcomeActivity;

/**
 * The DeviceAdminReceiver for this Sample
 *
 * @author honor mdm
 * @since 2019-10-23
 */
public class MdmBroadcastReceiver_Install extends DeviceAdminReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null) {
            return;
        }
        Bundle bundle = intent.getExtras();
            if (bundle != null) {
            String packageName = bundle.getString("packageName");
            int returnCode = bundle.getInt("returnCode");
            if (returnCode == 0) {//returnCode=0 的时候是静默安装成功
                //安装成功后更新
                if("con.kll.tv".equals(packageName)){
                    Intent intent1=new Intent(context, WellcomeActivity.class);
                    intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent1);
                }
            } else {//returncode != 0
                //业务逻辑处理
            }
        } else {
                //具体逻辑实现
        }
    }
}